import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { resolve } from "path";
import unocss from "unocss/vite";

function pathResolve(dir: string) {
  return resolve(process.cwd(), ".", dir);
}

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue(), unocss()],
  resolve: {
    alias: [
      {
        find: /\/@\//,
        replacement: pathResolve("src") + "/",
      },
      // /#/xxxx => types/xxxx
      {
        find: /\/#\//,
        replacement: pathResolve("types") + "/",
      },
    ],
  },
  css: {
    preprocessorOptions: {
      less: {
        additionalData: `@import "./src/theme/global.less";`,
      },
    },
  },
  server: {
    host: "0.0.0.0",
  },
});
